import java.util.Arrays;

public class Quiz {
	public static void main(String[] args) {
		String []a=new String[]{"a","JQ","a","JQ","c","JQ","d","e","f","g"}; 
		int k=0;
		for(int i=0;i<a.length;i++){
			if(a[i].equals("JQ")){
				k++;
				for(int j=i;j<a.length-k;j++){
					a[j]=a[j+1];
				}
				a[a.length-k]="";
				i--;
			}
			
		}
		
//		for(int i=0;i<a.length;i++){
//			System.out.println(a[i]);
//		}
		System.out.println(Arrays.toString(a));
		
		String [][]b=new String[(a.length-k+1)/2][2];
		for(int i=0;i<(a.length-k+1)/2;i++){
			for(int j=0;j<2;j++){
				b[i][j]=a[i*2+j];
			}
		}
//		for(int i=0;i<(a.length-k+1)/2;i++){
//			for(int j=0;j<2;j++){
//				System.out.print(b[i][j]);
//			}
//			System.out.println();
//		}
		System.out.println(Arrays.deepToString(b));
		String [][]c=new String[(a.length-k+1)/2][2];
		
		for(int i=0;i<(a.length-k+1)/2;i++){
			for(int j=0;j<2;j++){
				c[i][j]=b[(a.length-k+1)/2-i-1][1-j];
			}
		}
		System.out.println();
		/*for(int i=0;i<(a.length-k+1)/2;i++){
			for(int j=0;j<2;j++){
				System.out.print(c[i][j]);
			}
			System.out.println();
		}*/
		System.out.println(Arrays.deepToString(c));
		for(int i=0;i<(a.length-k+1)/2;i++){
			if(c[i][0].equals(c[i][1])){
				c[i][1]="";
			}
		}
		System.out.println();
		/*for(int i=0;i<(a.length-k+1)/2;i++){
			for(int j=0;j<2;j++){
				System.out.print(c[i][j]);
			}
			System.out.println();
		}*/
		System.out.println(Arrays.deepToString(c));
	}
}
